package com.xinfan.io.properties;

import java.io.*;
import java.util.Properties;

/**
 * @Author xin
 * @Date 2022/6/9 11:32
 * @Version 1.0
 */
public class Properties2_ {
    public static void main(String[] args) throws IOException {
        Properties properties = new Properties();
        //properties.load(new BufferedReader(new FileReader("src\\mysql.properties")));
        properties.load(new BufferedReader(new InputStreamReader(new FileInputStream("src\\mysql.properties"),"utf8")));
        properties.list(System.out);
        String user = properties.getProperty("user");//中文乱码
        System.out.println(user);

        //如果已经存在该属性就是修改值
        properties.setProperty("验证码","test");
        //BufferedWriter bw = new BufferedWriter(new FileWriter("src\\mysql2.properties"));

        properties.store(new FileOutputStream("src\\mysql2.properties"),"a");
        //properties.store(bw,"a");

    }
}
